﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace WindowsGame1
{
	public abstract class UIObject
	{
		public Vector2 Position;
		public Vector2 Size;
		public Color Clr;
		public Texture2D Texture;

        public UIObject ParentUIObj;


		public virtual Rectangle BoundingBox
		{
			get
			{
                if (ParentUIObj != null)
                {
                    return new Rectangle((int)(ParentUIObj.BoundingBox.X + Position.X), (int)(ParentUIObj.BoundingBox.Y + Position.Y), (int)Texture.Width, Texture.Height);
                }
                else
                {
                    return new Rectangle((int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y);
                }
			}
		}

		public UIObject()
		{
		}
        public UIObject(string texture, Vector2 position, UIObject parent)
        {
            this.Texture = Loader.LoadGameTexture(texture);
            
            this.ParentUIObj = parent;
            this.Position = (ParentUIObj != null) ? ParentUIObj.Position + position : position;
        }

		public virtual void Update(Vector2 position)
		{
			Position = position;
		}
	}
}
